/***
 * @param origin { Array }
 * @param children { String }
 * @param key { String }
 * @param callBack  { function }
 * 遍历树，并为每个节点传入回调函数
 */
export const treeEach = (origin = [], children = 'children', key = 'id',callBack = () => {}) => {
    if(!Array.isArray(origin) || origin.length === 0) return
    for(let i = 0; i<origin.length;i++) {
        if(origin[i][children]) {
            treeEach(origin[i][children],children,key,callBack)
        } else {
            callBack(origin[i])
        }
    }
}
